package com.lorianknights.rpg.managers
{
	
	import com.lorianknights.rpg.managers.Manager;
	import com.lorianknights.rpg.data.asset.Achievement;
	
	public class AchievementManager extends Manager 
	{
		
		private var _achs:Array;
		
		public function AchievementManager()
		{
			
			super();
			this._achs = [];
			
		}
		
		public function get achievementList():Array
		{
			
			return this._achs;
			
		}
		
		public function set achievementList(list:Array):void
		{
			
			this._achs = list;
			
		}
		
		public static function getAchievementByID(achID:int):Achievement
		{
			
			var i:int = 0;
			var achievement:Achievement = null;
			var n:Number = (this._achs.length);
			
				if (n > 0 && achID > 0)
				{
					
					while (i < n)
					{
						
						achievement = this._achs[i] as Achievement;
						
							if (achievement.achBase.intAchievementID == achID)
							{
								
								return achievement;
								i++;
								
							}
					}
				}
				
				return null;
				
		}
		
		public static function getAchievement(achievement:Achievement):Achievement
		{
			
			return this.getAchievementByID(achievement.achBase.intAchievementID) as Achievement;
			
		}
		
		public static function getAchievementTitleByID(achID:int):String
		{
			
			return this.getAchievement(achievementList[achID]).strTitle;
			
		}
		
		public static function getAchievementDescriptionByID(achID:int):String
		{
			
			return this.getAchievement(achievementList[achID]).strDesc;
			
		}
	}
}